<template>
  <h1>秒杀倒计时</h1>
  <van-count-down :time="time">
    <template #default="timeData">
      <span class="block">{{ timeData.hours }}</span>
      <span class="colon">:</span>
      <span class="block">{{ timeData.minutes }}</span>
      <span class="colon">:</span>
      <span class="block">{{ timeData.seconds }}</span>
    </template>
  </van-count-down>
  <ul class="img-box">
    <li v-for="item in goodslist" :key="item.proid">
      <router-link :to="{ name: 'gooddetail', params: { id: item.proid } }">
        <img :src="item.img1"
      /></router-link>
    </li>
  </ul>
</template>

<script>
export default {
  name: "SecondsKill",
  data() {
    return {
      time: 5 * 60 * 3600,
      goodslist: [],
    };
  },
  components: {},
  created() {
    this.getGoodsList();
  },
  methods: {
    getGoodsList() {
      this.$http({
        url: "/pro/seckilllist",
        params: {
          count: 2,
          limitNum: 4,
        },
      }).then((res) => {
        if (res.data.code === "200") {
          // console.log(res.data.data);
          this.goodslist = res.data.data;
        }
      });
    },
  },
};
</script>

<style scoped>
.colon {
  display: inline-block;
  margin: 0 4px;
  color: #1989fa;
}
.block {
  display: inline-block;
  width: 22px;
  color: #fff;
  font-size: 12px;
  text-align: center;
  background-color: #fa1919;
}
.img-box {
  width: 100%;
  height: 200px;
  overflow-x: auto;
  display: flex;
}
.img-box li {
  margin: 0 auto;
}
.img-box img {
  height: 80%;
  border: 1px solid black;
  margin: 5px 5px;
}
</style>